using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using gudusoft.gsqlparser;
using gudusoft.gsqlparser.Units;
using System.Diagnostics;

namespace OracleJoinConverter
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void btnConvert_Click(object sender, EventArgs e)
        {
            oracleJoinConverter c = new oracleJoinConverter(txtInput.Text.Trim());
            c.convert();
            txtOutput.Text = format(c.getQuery());
            
        }

        private string format(string sql)
        {
            TGSqlParser sqlparser = new TGSqlParser(TDbVendor.DbVOracle);
            sqlparser.SqlText.Text = sql;
            if (sqlparser.PrettyPrint() == 0)
            {
                return sqlparser.FormattedSqlText.Text;
            }
            else
            {
                return sql;
            }
            
        }

        private void button1_Click(object sender, EventArgs e)
        {
            Process ps = new Process();
            string yourURL="http://www.dpriver.com/blog/list-of-demos-illustrate-how-to-use-general-sql-parser/";  
            ps.StartInfo.FileName="iexplore.exe";  
            ps.StartInfo.Arguments=yourURL;  
            ps.Start();  
        }
    }
}